//分页类
	
function pager($total, $page, $pagesize, callback)
{
	this.total = parseInt($total);
	this.page = $page ? parseInt($page) : 1;
	this.pagesize = parseInt($pagesize);
	this.page_total = Math.ceil(this.total/this.pagesize);
	
	//取得分页HTML
	this.get_html = function()
	{
		var $html = '<span class="now">'+ (this.page) +'</span>/'+ (this.page_total) +'('+ (this.total) +')';
		
		if(this.page > 1)
		{
			$html += '<a page="1" href="###">首页</a> ';
			$html += '<a page="'+ (this.page-1) +'" href="###">上一页</a> ';
		}
		
		//索引页小于3或者总页数-当前页<10,从第一页开始显示
		var $pager_start, $max_page;
		if(this.page < 3 || this.page_total <=10)
		{
			$pager_start = 1;
			$max_page = Math.min(10, this.page_total);
		} else if (this.page_total - this.page < 10){	//到最后几页了，取最后十个
			$pager_start = this.page_total - 10 + 1;
			$max_page = this.page_total;
		} else {	//取中间十个
			$pager_start = this.page - 2;
			$max_page = $pager_start + 10 - 1;
		}
		for($i=$pager_start; $i<=$max_page; $i++)
		{
			var $class = this.page == $i ? "class='now'" : "";
			$html += '<a page="'+$i+'" href="###" '+$class+' >'+$i+'</a> ';
		}
		
		if(this.page < this.total)
		{
			$html += '<a page="'+ (this.page+1) +'" href="###">下一页</a> ';
			$html += '<a page="'+ (this.total_page) +'" href="###">末页</a>';
		}
		
		var $form = $('<form class="page"></form>');
		$form.html($html).find("a").click(function(){
			var $p = $(this).attr("page");
			if($p) callback($p);
		});
		return $form;
	}
	
}